//
//  LiveStreamingData.m
//  YouinRTCDemo
//
//  Created by 潘欣 on 2025/5/26.
//

#import "LiveStreamingData.h"
#import <LSTPopView/LSTPopView.h>
#import "DataHeaderView.h"
#import "DataCollectionViewCell.h"
#import "DataShareCollectionViewCell.h"
@interface LiveStreamingData ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@property (nonatomic,weak) LSTPopView *popView;
@property (nonatomic,strong)UILabel *fangwenLabel;
@property (nonatomic,strong)UILabel *wenLabel;//总访问人次
@property (nonatomic,strong)UILabel *peopleLabel;//总访问人数
@property (nonatomic,strong)UILabel *watchLabel;//总观看人数

@property (nonatomic,strong)UILabel *rateLabel;//转化率
@property (nonatomic,strong)UILabel *timeLabel;//观看时长
@property (nonatomic,strong)UILabel *onlineLabel;//最高在线


///分享
@property (nonatomic,strong)UILabel *shareLabel;
@property (nonatomic,strong)UILabel *countLabel;//分享次数
@property (nonatomic,strong)UILabel *inviteLabel;//邀请人数
@property (nonatomic,strong)UILabel *goodLabel;//有效邀请人数
@property (nonatomic,strong)UILabel *newsLabel;//本场拉新

@property (nonatomic,strong)UILabel *hudongLabel;//互动

@property (nonatomic,strong)UILabel *likeLabel;//点击次数
@property (nonatomic,strong)UILabel *redLabel;//红包总额
@property (nonatomic,strong)UILabel *giftsLabel;//礼物收益



@property (nonatomic,strong)UILabel *tradeLabel;//交易
@property (nonatomic,strong)UILabel *clickLabel;//点击次数
@property (nonatomic,strong)UILabel *goodsLabel;//商品点击次数
@property (nonatomic,strong)UILabel *purchaseLabel;//购买人数
@property (nonatomic,strong)UILabel *ordersLabel;//订单数
@property (nonatomic,strong)UILabel *moneyLabel;//累计订单金额
@property (nonatomic,strong)UILabel *refoundLabel;//成功退款金额

@property (nonatomic,strong)UICollectionView *collectionView;
@property (nonatomic,strong)NSMutableArray *datasArray;

@end
@implementation LiveStreamingData

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = RYColorForHex(@"#F9F9F9");
        self.datasArray = [[NSMutableArray alloc] initWithCapacity:0];
        
    
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.textColor = RYColorForHex(@"#333333");
        titleLabel.text = @"直播数据";
        titleLabel.backgroundColor = [UIColor whiteColor];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
        [self addSubview:titleLabel];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.centerX.width.mas_equalTo(self);
            make.height.offset(44);
        }];

        [self.collectionView registerClass:[DataHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"DataHeaderView1"];
        //访问
        [self.collectionView registerClass:[DataCollectionViewCell class] forCellWithReuseIdentifier:@"UICollectionViewCell"];
        
        //分享
        [self.collectionView registerClass:[DataCollectionViewCell class] forCellWithReuseIdentifier:@"DataCollectionViewCell2"];
        //互动
        [self.collectionView registerClass:[DataCollectionViewCell class] forCellWithReuseIdentifier:@"UICollectionViewCell3"];
        //交易
        [self.collectionView registerClass:[DataCollectionViewCell class] forCellWithReuseIdentifier:@"UICollectionViewCell4"];
        
        [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"UICollectionReusableViewfooter"];
        
        
        [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self).offset(12);
            make.right.bottom.mas_equalTo(self).offset(-12);
            make.top.mas_equalTo(titleLabel.mas_bottom);
        }];
        
//
//        UIView *fangwenView = [[UIView alloc] init];
//        fangwenView.backgroundColor = [UIColor whiteColor];
//        fangwenView.layer.cornerRadius = 5;
//        fangwenView.clipsToBounds = YES;
//        [self addSubview:fangwenView];
//        
//        [fangwenView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.mas_equalTo(self).offset(10);
//            make.right.mas_equalTo(self).offset(-10);
//            make.top.mas_equalTo(titleLabel.mas_bottom).offset(20);
//            make.height.offset(160);
//        }];
//        
//        
//        UIImageView *fangwenImg = [[UIImageView alloc] init];
//        fangwenImg.image = [UIImage imageNamed:@"fangwen_icon"];
//        [fangwenView addSubview:fangwenImg];
//        
//        [fangwenImg mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.left.width.mas_equalTo(fangwenView);
//            make.height.offset(36);
//        }];
//        
//        self.fangwenLabel = [[UILabel alloc] init];
//        self.fangwenLabel.textColor =RYColorForHex(@"#333333");
//        self.fangwenLabel.text = @"访问";
//        self.fangwenLabel.font = [UIFont systemFontOfSize:14];
//        [fangwenView addSubview:self.fangwenLabel];
//        
//        [self.fangwenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.mas_equalTo(fangwenImg).offset(40);
//            make.centerY.mas_equalTo(fangwenImg);
//        }];
//                
//        
//        self.wenLabel = [[UILabel alloc] init];
//        self.wenLabel.textColor =RYColorForHex(@"#000000");
//        self.wenLabel.text = @"总访问人次\n0";
//        self.wenLabel.numberOfLines = 0;
//        self.wenLabel.textAlignment = NSTextAlignmentCenter;
//        self.wenLabel.font = [UIFont systemFontOfSize:12];
//        [fangwenView addSubview:self.wenLabel];
//        
//        [self.wenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.mas_equalTo(fangwenView).offset(9);
//            make.top.mas_equalTo(fangwenImg.mas_bottom).offset(10);
//        }];
//        
//        
//        self.peopleLabel = [[UILabel alloc] init];
//        self.peopleLabel.textColor = RYColorForHex(@"#000000");
//        self.peopleLabel.text = @"总访问人数\n0";
//        self.peopleLabel.numberOfLines = 0;
//        self.peopleLabel.textAlignment = NSTextAlignmentCenter;
//        self.peopleLabel.font = [UIFont systemFontOfSize:12];
//        [fangwenView addSubview:self.peopleLabel];
//        
//        [self.peopleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerX.mas_equalTo(fangwenView);
//            make.top.mas_equalTo(self.fangwenLabel.mas_bottom).offset(20);
//        }];
//        
//        self.watchLabel = [[UILabel alloc] init];
//        self.watchLabel.textColor =RYColorForHex(@"#000000");
//        self.watchLabel.text = @"总观看人数\n0";
//        self.watchLabel.numberOfLines = 0;
//        self.watchLabel.textAlignment = NSTextAlignmentCenter;
//        self.watchLabel.font = [UIFont systemFontOfSize:12];
//        [fangwenView addSubview:self.watchLabel];
//        
//        [self.watchLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.right.mas_equalTo(fangwenView).offset(-10);
//            make.top.mas_equalTo(self.fangwenLabel.mas_bottom).offset(20);
//        }];
//        
//        
//        self.rateLabel = [[UILabel alloc] init];
//        self.rateLabel.textColor =RYColorForHex(@"#000000");
//        self.rateLabel.text = @"观看转化率\n0";
//        self.rateLabel.numberOfLines = 0;
//        self.rateLabel.textAlignment = NSTextAlignmentCenter;
//        self.rateLabel.font = [UIFont systemFontOfSize:12];
//        [fangwenView addSubview:self.rateLabel];
//        
//        [self.rateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.mas_equalTo(fangwenView).offset(10);
//            make.bottom.mas_equalTo(fangwenView.mas_bottom).offset(-20);
//        }];
//        
//        self.timeLabel = [[UILabel alloc] init];
//        self.timeLabel.textColor =RYColorForHex(@"#000000");
//        self.timeLabel.text = @"人均观看时长\n0";
//        self.timeLabel.numberOfLines = 0;
//        self.timeLabel.textAlignment = NSTextAlignmentCenter;
//        self.timeLabel.font = [UIFont systemFontOfSize:12];
//        [fangwenView addSubview:self.timeLabel];
//        
//        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerX.mas_equalTo(fangwenView);
//            make.bottom.mas_equalTo(fangwenView.mas_bottom).offset(-20);
//        }];
//        
//        
//        self.onlineLabel = [[UILabel alloc] init];
//        self.onlineLabel.textColor =RYColorForHex(@"#000000");
//        self.onlineLabel.text = @"最高在线\n0";
//        self.onlineLabel.numberOfLines = 0;
//        self.onlineLabel.textAlignment = NSTextAlignmentCenter;
//        self.onlineLabel.font = [UIFont systemFontOfSize:12];
//        [fangwenView addSubview:self.onlineLabel];
//        
//        [self.onlineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.right.mas_equalTo(fangwenView).offset(-10);
//            make.bottom.mas_equalTo(fangwenView.mas_bottom).offset(-20);
//        }];
//        
//        
//        
//        //分享
//        UIView *shareView = [[UIView alloc] init];
//        shareView.backgroundColor = [UIColor whiteColor];
//        shareView.layer.cornerRadius = 5;
//        shareView.clipsToBounds = YES;
//        [self addSubview:shareView];
//        
//        [shareView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.right.mas_equalTo(fangwenView);
//            make.top.mas_equalTo(fangwenView.mas_bottom).offset(20);
//            make.height.offset(110);
//        }];
//        
//        
//        
//        
//        self.shareLabel = [[UILabel alloc] init];
//        self.shareLabel.textColor =RYColorForHex(@"#000000");
//        self.shareLabel.text = @"分享";
//        self.shareLabel.font = [UIFont systemFontOfSize:18];
//        [shareView addSubview:self.shareLabel];
//        
//        [self.shareLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.left.mas_equalTo(shareView).offset(10);
//        }];
//        
//        self.countLabel = [[UILabel alloc] init];
//        self.countLabel.textColor =RYColorForHex(@"#000000");
//        self.countLabel.text = @"分享次数\n0";
//        self.countLabel.numberOfLines = 0;
//        self.countLabel.textAlignment = NSTextAlignmentCenter;
//        self.countLabel.font = [UIFont systemFontOfSize:12];
//        [shareView addSubview:self.countLabel];
//        
//        [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.mas_equalTo(shareView).offset(20);
//            make.bottom.mas_equalTo(shareView.mas_bottom).offset(-20);
//        }];
//        
//        
//        
//        self.newsLabel = [[UILabel alloc] init];
//        self.newsLabel.textColor =RYColorForHex(@"#000000");
//        self.newsLabel.text = @"本场拉新\n0";
//        self.newsLabel.numberOfLines = 0;
//        self.newsLabel.textAlignment = NSTextAlignmentCenter;
//        self.newsLabel.font = [UIFont systemFontOfSize:12];
//        [shareView addSubview:self.newsLabel];
//        
//        [self.newsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.right.mas_equalTo(shareView).offset(-20);
//            make.bottom.mas_equalTo(shareView.mas_bottom).offset(-20);
//        }];
//        
//        
//        self.inviteLabel = [[UILabel alloc] init];
//        self.inviteLabel.textColor =RYColorForHex(@"#000000");
//        self.inviteLabel.text = @"邀请人数\n0";
//        self.inviteLabel.numberOfLines = 0;
//        self.inviteLabel.textAlignment = NSTextAlignmentCenter;
//        self.inviteLabel.font = [UIFont systemFontOfSize:12];
//        [shareView addSubview:self.inviteLabel];
//        
//        [self.inviteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.mas_equalTo(self.countLabel.mas_right).offset(40);
//            make.bottom.mas_equalTo(shareView.mas_bottom).offset(-20);
//        }];
//        
//        
//        
//        self.goodLabel = [[UILabel alloc] init];
//        self.goodLabel.textColor =RYColorForHex(@"#000000");
//        self.goodLabel.text = @"有效邀请人数\n0";
//        self.goodLabel.numberOfLines = 0;
//        self.goodLabel.textAlignment = NSTextAlignmentCenter;
//        self.goodLabel.font = [UIFont systemFontOfSize:12];
//        [shareView addSubview:self.goodLabel];
//        
//        [self.goodLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.right.mas_equalTo(self.newsLabel.mas_left).offset(-40);
//            make.bottom.mas_equalTo(shareView.mas_bottom).offset(-20);
//        }];
//        
//        
//        //互动
//        UIView *hudongView = [[UIView alloc] init];
//        hudongView.backgroundColor = [UIColor whiteColor];
//        hudongView.layer.cornerRadius = 5;
//        hudongView.clipsToBounds = YES;
//        [self addSubview:hudongView];
//        
//        [hudongView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.right.mas_equalTo(shareView);
//            make.top.mas_equalTo(shareView.mas_bottom).offset(20);
//            make.height.offset(110);
//        }];
//        
//        
//        
//        
//        self.hudongLabel = [[UILabel alloc] init];
//        self.hudongLabel.textColor =RYColorForHex(@"#000000");
//        self.hudongLabel.text = @"互动";
//        self.hudongLabel.font = [UIFont systemFontOfSize:18];
//        [hudongView addSubview:self.hudongLabel];
//        [self.hudongLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.left.mas_equalTo(hudongView).offset(10);
//        }];
//        
//        
//        
//        self.likeLabel = [[UILabel alloc] init];
//        self.likeLabel.textColor =RYColorForHex(@"#000000");
//        self.likeLabel.text = @"点赞次数\n0";
//        self.likeLabel.numberOfLines = 0;
//        self.likeLabel.textAlignment = NSTextAlignmentCenter;
//        self.likeLabel.font = [UIFont systemFontOfSize:12];
//        [hudongView addSubview:self.likeLabel];
//        
//        [self.likeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.mas_equalTo(hudongView).offset(10);
//            make.top.mas_equalTo(self.hudongLabel.mas_bottom).offset(20);
//        }];
//        
//        
//        self.redLabel = [[UILabel alloc] init];
//        self.redLabel.textColor =RYColorForHex(@"#000000");
//        self.redLabel.text = @"红包总额（元）\n0";
//        self.redLabel.numberOfLines = 0;
//        self.redLabel.textAlignment = NSTextAlignmentCenter;
//        self.redLabel.font = [UIFont systemFontOfSize:12];
//        [hudongView addSubview:self.redLabel];
//        
//        [self.redLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerX.mas_equalTo(hudongView);
//            make.top.mas_equalTo(self.hudongLabel.mas_bottom).offset(20);
//        }];
//        
//        self.giftsLabel = [[UILabel alloc] init];
//        self.giftsLabel.textColor =RYColorForHex(@"#000000");
//        self.giftsLabel.text = @"礼物收益（元）\n0";
//        self.giftsLabel.numberOfLines = 0;
//        self.giftsLabel.textAlignment = NSTextAlignmentCenter;
//        self.giftsLabel.font = [UIFont systemFontOfSize:12];
//        [hudongView addSubview:self.giftsLabel];
//        
//        [self.giftsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.right.mas_equalTo(hudongView).offset(-10);
//            make.top.mas_equalTo(self.hudongLabel.mas_bottom).offset(20);
//        }];
//        
//        
//        
//        
//        //交易
//        UIView *tradeView = [[UIView alloc] init];
//        tradeView.backgroundColor = [UIColor whiteColor];
//        tradeView.layer.cornerRadius = 5;
//        tradeView.clipsToBounds = YES;
//        [self addSubview:tradeView];
//        
//        [tradeView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.right.mas_equalTo(hudongView);
//            make.top.mas_equalTo(hudongView.mas_bottom).offset(20);
//            make.height.offset(160);
//        }];
//        
//        
//        self.tradeLabel = [[UILabel alloc] init];
//        self.tradeLabel.textColor =RYColorForHex(@"#000000");
//        self.tradeLabel.text = @"交易";
//        self.tradeLabel.font = [UIFont systemFontOfSize:18];
//        [tradeView addSubview:self.tradeLabel];
//        [self.tradeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.left.mas_equalTo(tradeView).offset(10);
//        }];
//        
//        self.clickLabel = [[UILabel alloc] init];
//        self.clickLabel.textColor =RYColorForHex(@"#000000");
//        self.clickLabel.text = @"商品点击次数\n0";
//        self.clickLabel.numberOfLines = 0;
//        self.clickLabel.textAlignment = NSTextAlignmentCenter;
//        self.clickLabel.font = [UIFont systemFontOfSize:12];
//        [tradeView addSubview:self.clickLabel];
//        
//        [self.clickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.mas_equalTo(tradeView).offset(10);
//            make.top.mas_equalTo(self.tradeLabel.mas_bottom).offset(20);
//        }];
//        
//        
//        self.goodsLabel = [[UILabel alloc] init];
//        self.goodsLabel.textColor =RYColorForHex(@"#000000");
//        self.goodsLabel.text = @"商品点击人数\n0";
//        self.goodsLabel.numberOfLines = 0;
//        self.goodsLabel.textAlignment = NSTextAlignmentCenter;
//        self.goodsLabel.font = [UIFont systemFontOfSize:12];
//        [tradeView addSubview:self.goodsLabel];
//        
//        [self.goodsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerX.mas_equalTo(tradeView);
//            make.top.mas_equalTo(self.tradeLabel.mas_bottom).offset(20);
//        }];
//        
//        
//        self.purchaseLabel = [[UILabel alloc] init];
//        self.purchaseLabel.textColor =RYColorForHex(@"#000000");
//        self.purchaseLabel.text = @"购买人数\n0";
//        self.purchaseLabel.numberOfLines = 0;
//        self.purchaseLabel.textAlignment = NSTextAlignmentCenter;
//        self.purchaseLabel.font = [UIFont systemFontOfSize:12];
//        [tradeView addSubview:self.purchaseLabel];
//        
//        [self.purchaseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.right.mas_equalTo(tradeView).offset(-10);
//            make.top.mas_equalTo(self.tradeLabel.mas_bottom).offset(20);
//        }];
//        
//        
//        self.ordersLabel = [[UILabel alloc] init];
//        self.ordersLabel.textColor =RYColorForHex(@"#000000");
//        self.ordersLabel.text = @"订单数\n0";
//        self.ordersLabel.numberOfLines = 0;
//        self.ordersLabel.textAlignment = NSTextAlignmentCenter;
//        self.ordersLabel.font = [UIFont systemFontOfSize:12];
//        [tradeView addSubview:self.ordersLabel];
//        
//        [self.ordersLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.mas_equalTo(tradeView).offset(10);
//            make.bottom.mas_equalTo(tradeView.mas_bottom).offset(-20);
//        }];
//        
//        self.moneyLabel = [[UILabel alloc] init];
//        self.moneyLabel.textColor =RYColorForHex(@"#000000");
//        self.moneyLabel.text = @"累计订单金额（元）\n0";
//        self.moneyLabel.numberOfLines = 0;
//        self.moneyLabel.textAlignment = NSTextAlignmentCenter;
//        self.moneyLabel.font = [UIFont systemFontOfSize:12];
//        [tradeView addSubview:self.moneyLabel];
//        
//        [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerX.mas_equalTo(tradeView);
//            make.bottom.mas_equalTo(tradeView.mas_bottom).offset(-20);
//        }];
//        
//        self.refoundLabel = [[UILabel alloc] init];
//        self.refoundLabel.textColor =RYColorForHex(@"#000000");
//        self.refoundLabel.text = @"成功退款金额（元）\n0";
//        self.refoundLabel.numberOfLines = 0;
//        self.refoundLabel.textAlignment = NSTextAlignmentCenter;
//        self.refoundLabel.font = [UIFont systemFontOfSize:12];
//        [tradeView addSubview:self.refoundLabel];
//        
//        [self.refoundLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.right.mas_equalTo(tradeView).offset(-10);
//            make.bottom.mas_equalTo(tradeView.mas_bottom).offset(-20);
//        }];
//        
//        
//        
//        UILabel *dataLabel = [[UILabel alloc] init];
//        dataLabel.textColor = [UIColor grayColor];
//        dataLabel.text = @"更多数据请前往电脑端查看";
//        dataLabel.font = [UIFont systemFontOfSize:12];
//        [self addSubview:dataLabel];
//        
//        [dataLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.mas_equalTo(tradeView.mas_bottom).offset(10);
//            make.left.mas_equalTo(tradeView).offset(10);
//        }];
    }
    return self;
}

- (void)liveData:(NSDictionary *)data
{
    self.datasArray = [NSMutableArray new];
    
    NSArray *data1 = [NSArray arrayWithObjects:
                      [NSString stringWithFormat:@"%@",data[@"pv_count"]],
                      [NSString stringWithFormat:@"%@",data[@"uv_count"]],
                      [NSString stringWithFormat:@"%@",data[@"watchUserCount"]],
                      [NSString stringWithFormat:@"%.1f%%",[data[@"watchUserCount"] floatValue]/[data[@"uv_count"] floatValue]*100],
                      [NSString stringWithFormat:@"%@",data[@"agv_duration"]],
                      [NSString stringWithFormat:@"%@",data[@"max_watch_count"]],
                      nil];
    
    NSArray *data2 = [NSArray arrayWithObjects:
                      [NSString stringWithFormat:@"%@",data[@"share_count"]],
                      [NSString stringWithFormat:@"%@",data[@"valid_share_count"]],
                      [NSString stringWithFormat:@"%@",data[@"invite_user_count"]],
                      [NSString stringWithFormat:@"%@",data[@"new_user_count"]],
                      nil];
    
    
    NSArray *data3 = [NSArray arrayWithObjects:
                      [NSString stringWithFormat:@"%@",data[@"like_count"]],
                      [NSString stringWithFormat:@"%@",data[@"red_packet_amount"]],
                      [NSString stringWithFormat:@"%@",data[@"gift_amount"]],
                      nil];
    
    
    
    NSArray *data4 = [NSArray arrayWithObjects:
                      [NSString stringWithFormat:@"%@",data[@"click_product_count"]],
                      [NSString stringWithFormat:@"%@",data[@"click_product_user_count"]],
                      [NSString stringWithFormat:@"%@",[self objectForKeyPath:data[@"statistics_trade_live"][@"userPayCount"]]?@"0":data[@"statistics_trade_live"][@"userPayCount"]],
                      [NSString stringWithFormat:@"%@",[self objectForKeyPath:data[@"statistics_trade_live"][@"orderPayCount"]]?@"0":data[@"statistics_trade_live"][@"orderPayCount"]],
                      [NSString stringWithFormat:@"%@",[self objectForKeyPath:data[@"statistics_trade_live"][@"orderPayPrice"]]?@"0.00":data[@"statistics_trade_live"][@"orderPayPrice"]],
                      [NSString stringWithFormat:@"%@",[self objectForKeyPath:data[@"statistics_trade_live"][@"afterSaleRefundPrice"]]?@"0.00":data[@"statistics_trade_live"][@"afterSaleRefundPrice"]],
                      nil];
    
    [self.datasArray addObject:data1];
    [self.datasArray addObject:data2];
    [self.datasArray addObject:data3];
    [self.datasArray addObject:data4];
    

    
//    self.wenLabel.text = [NSString stringWithFormat:@"总访问人次\n%@",data[@"pv_count"]];
//    self.peopleLabel.text = [NSString stringWithFormat:@"总访问人数\n%@",data[@"uv_count"]];
//    self.watchLabel.text = [NSString stringWithFormat:@"总观看人数\n%@",data[@"watchUserCount"]];
//    self.rateLabel.text = [NSString stringWithFormat:@"观看转化率\n%.1f%%",[data[@"watchUserCount"] floatValue]/[data[@"uv_count"] floatValue]*100];
//    self.timeLabel.text = [NSString stringWithFormat:@"人均观看时长\n%@",data[@"agv_duration"]];
//    self.onlineLabel.text = [NSString stringWithFormat:@"最高在线\n%@",data[@"max_watch_count"]];
//
    
    
//    self.countLabel.text = [NSString stringWithFormat:@"分享次数\n%@",data[@"share_count"]];
//    self.inviteLabel.text = [NSString stringWithFormat:@"邀请人数\n%@",data[@"valid_share_count"]];
//    self.goodLabel.text = [NSString stringWithFormat:@"有效邀请人数\n%@",data[@"invite_user_count"]];
//    self.newsLabel.text = [NSString stringWithFormat:@"本场拉新\n%@",data[@"new_user_count"]];
//    
//    
//    self.likeLabel.text = [NSString stringWithFormat:@"点赞次数\n%@",data[@"like_count"]];
//    self.redLabel.text = [NSString stringWithFormat:@"红包总额（元）\n%@",data[@"red_packet_amount"]];
//    self.giftsLabel.text = [NSString stringWithFormat:@"礼物收益（元）\n%@",data[@"gift_amount"]];
//    
//    
//    self.clickLabel.text = [NSString stringWithFormat:@"商品点击次数\n%@",data[@"click_product_count"]];
//    self.goodsLabel.text = [NSString stringWithFormat:@"商品点击人数\n%@",data[@"click_product_user_count"]];
//    self.purchaseLabel.text = [NSString stringWithFormat:@"购买人数\n%@",data[@"statistics_trade_live"][@"userPayCount"]];
//    self.ordersLabel.text = [NSString stringWithFormat:@"订单数\n%@",data[@"statistics_trade_live"][@"orderPayCount"]];
//    self.moneyLabel.text = [NSString stringWithFormat:@"累计订单金额（元）\n%@",data[@"statistics_trade_live"][@"orderPayPrice"]];
//    self.refoundLabel.text = [NSString stringWithFormat:@"成功退款金额（元）\n%@",data[@"statistics_trade_live"][@"afterSaleRefundPrice"]];
    
    [self.collectionView reloadData];
}

- (nullable id)objectForKeyPath:(NSString *)keyPath {
    NSString *stringValue = keyPath;
    if ([keyPath isKindOfClass:[NSNumber class]]) {
        
        stringValue = [NSString stringWithFormat:@"%@",keyPath];
    }
    NSArray *keys = [stringValue componentsSeparatedByString:@"."];
    id result = self;
    
    for (NSString *key in keys) {
        if (![result isKindOfClass:[NSDictionary class]]) {
            return nil;
        }
        result = result[key];
        if (result == [NSNull null]) {
            return @"0";
        }
    }
    return result;
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 4;
}
/**
 返回表格视图当前组行数
 
 @param collectionView 表格视图对象
 @param section 当前组
 @return 行数
 */
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

    if (section == 0) {//访问
        return 6;
    }else if (section == 1)//分享
    {
        return 4;
    }
    else if (section == 2)//互动
    {
        return 3;
    }else {
        return 6;
    }
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell *collectionViewCell = nil;
    if (indexPath.section == 0) {
        DataCollectionViewCell *onlineCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"UICollectionViewCell" forIndexPath:indexPath];
        [onlineCell dataSection:indexPath.section withIndex:indexPath.row withData:self.datasArray];
        collectionViewCell = onlineCell;
    }else if (indexPath.section == 1)
    {
        DataCollectionViewCell *shareCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DataCollectionViewCell2" forIndexPath:indexPath];
        [shareCell dataSection:indexPath.section withIndex:indexPath.row withData:self.datasArray];
        collectionViewCell = shareCell;
    }else if (indexPath.section == 2)
    {
        DataCollectionViewCell *hudongCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"UICollectionViewCell3" forIndexPath:indexPath];
        [hudongCell dataSection:indexPath.section withIndex:indexPath.row withData:self.datasArray];
        collectionViewCell = hudongCell;
    }else{
        DataCollectionViewCell *purcharseCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"UICollectionViewCell4" forIndexPath:indexPath];
        [purcharseCell dataSection:indexPath.section withIndex:indexPath.row withData:self.datasArray];
        collectionViewCell = purcharseCell;
    }
    
    return collectionViewCell;
}

// size for item  (ScreenWidth-8*(5-1))/5
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section == 1) return  CGSizeMake((SCREEN_WIDTH-25-25)/2, 60);
    return CGSizeMake((SCREEN_WIDTH-24-24-9)/3, 60);
}

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
    // 1.创建一个视图对象
    UICollectionReusableView *collectionReusableView = nil;
    // 2.1.头部视图
    if (kind == UICollectionElementKindSectionHeader){

        DataHeaderView *bannerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"DataHeaderView1" forIndexPath:indexPath];
        bannerView.index = indexPath.section;
        collectionReusableView = bannerView;
    }
    
    if (kind == UICollectionElementKindSectionFooter)
    {
        // 表格尾部视图：分割线
        UICollectionReusableView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"UICollectionReusableViewfooter" forIndexPath:indexPath];
        footerView.backgroundColor = RYColorForHex(@"#f9f9f9");
        if (indexPath.section == 3) {
            UILabel *footerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 20)];
            footerLabel.text = @"---  更多数据请前往电脑端查看  ---";
            footerLabel.textColor = RYColorForHex(@"#888888");
            footerLabel.font = [UIFont systemFontOfSize:12];
            footerLabel.textAlignment = NSTextAlignmentCenter;
            [footerView addSubview:footerLabel];
            footerView.backgroundColor = [UIColor whiteColor];
        }
        collectionReusableView = footerView;
    }
    // 3.返回当前视图
    return collectionReusableView;
}
/**
 返回当前组的头部视图尺寸
 
 @param collectionView 表格视图对象
 @param collectionViewLayout 布局样式
 @param section 当前组
 @return 尺寸
 */
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
    return CGSizeMake(SCREEN_WIDTH, 40);
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
    
    if (section == 3) return  CGSizeMake(SCREEN_WIDTH, 20);
    return  CGSizeMake(SCREEN_WIDTH, 10);
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(8,9,8,9);
}

- (UICollectionView *)collectionView {
    if (nil == _collectionView) {
        UICollectionViewFlowLayout *collectionViewFlowLayout = [[UICollectionViewFlowLayout alloc] init];
        collectionViewFlowLayout.minimumInteritemSpacing =  0;
        collectionViewFlowLayout.minimumLineSpacing = 8;
        collectionViewFlowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:collectionViewFlowLayout];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        if (@available(iOS 11.0, *)) {
            _collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        } else {
            // Fallback on earlier versions
        }
        
        _collectionView.showsVerticalScrollIndicator = NO;
        _collectionView.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.collectionView];
    }
    
    return _collectionView;
}

-(void)showView
{
    LSTPopView *popView = [LSTPopView initWithCustomView:self
                                                popStyle:LSTPopStyleSmoothFromBottom
                                            dismissStyle:LSTDismissStyleSmoothToBottom];

    popView.hemStyle = LSTHemStyleBottom;
    popView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5];
    LSTPopViewWK(popView)
    popView.popDuration = 0.5;
    popView.dismissDuration = 0.5;
    popView.isClickFeedback = YES;
    popView.rectCorners = UIRectCornerTopLeft | UIRectCornerTopRight;
    popView.cornerRadius = 15;
    popView.sweepStyle = LSTSweepStyleY_Positive;
    popView.dragStyle = LSTDragStyleY_Positive;
    popView.sweepDismissStyle = LSTSweepDismissStyleSmooth;
    popView.bgClickBlock = ^{
        NSLog(@"点击了背景");
        [wk_popView dismiss];
    };
    self.popView = popView;

    [popView pop];
}

-(void)hideView;
{
    [self.popView dismiss];
}
-(void)dealloc
{
    NSLog(@"dealloc");
}



@end
